package com.ssh.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ssh.model.User;

public class UserDaoImpl extends HibernateDaoSupport {
	public void saveUser(User user) {
		getHibernateTemplate().save(user);
	}

	public User getUserById(int id) {
		User user = (User) getSession().createQuery(
				"from User where id = :id").setInteger("id", id).uniqueResult();
		return user;
	}

	public void deleteUser(User user) {
		getHibernateTemplate().delete(user);
	}

	public List<User> getAllUsers() {
		List<User> userList = getSession().createQuery("from User").list();
		return userList;
	}
	
	public void modifyUser(User user) {
		getHibernateTemplate().update(user);
	}

}
